package net.arvin.view;

import net.arvin.mobilebanksystem.R;
import net.arvin.view.NormalDialog.MyDialogListener;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TransfersDialog extends Dialog implements OnClickListener {

	public Context mContext;
	private LinearLayout btn_cancel;
	private LinearLayout btn_ensure;
	public EditText inputContent;
	public TextView transfers;

	private MyDialogListener mListener;

	public TransfersDialog(Context context, int theme, MyDialogListener listener) {
		super(context, theme);
		this.mContext = context;
		setContentView(R.layout.dialog_transfers);
		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
		int screenWidth = (int) (metrics.widthPixels * 0.90);
		getWindow().setLayout(screenWidth, LayoutParams.WRAP_CONTENT);
		this.mListener = listener;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initView();
	}

	private void initView() {
		btn_ensure = (LinearLayout) getWindow().findViewById(
				R.id.dialog_btn_ensure);
		btn_ensure.setOnClickListener(this);
		btn_cancel = (LinearLayout) getWindow().findViewById(
				R.id.dialog_btn_cancel);
		btn_cancel.setOnClickListener(this);
	}

	// 调用该方法，改变提示和输入框提示的内容
	public void setTransfersText(String phonenumber, String money) {
		transfers.setText("您将向" + phonenumber + "用户转账" + money);
	}

	public String getInputContent() {
		return inputContent.getText().toString().trim();
	}

	@Override
	public void onClick(View v) {
		mListener.onClick(v);
	}
}
